// pages/course/courseDetails/courseDetails.js
// 引入全局的app.js文件对象
const app = getApp();
Page({

    /**
   * 页面的初始数据
   */
    data: {
        current: 0,
        titleList: ["课程详情", "课程列表", "名师介绍", "课堂交流", "课程介绍"],
        // 课程详情数据
        courseDetailData: {},
        url:'',
        course:'',
        teacher:''
        
    },

    // 选择scroll-view中的标题事件
    chooseItem(e) {
        //console.log(e.target.dataset.index)
        this.setData({
            current: e.target.dataset.index
        })
    },

    // swiper的change事件函数
    swiperChanged(e) {
        // console.log(e.detail.current)
        this.setData({
            current: e.detail.current
        })
    },

    /**
   * 生命周期函数--监听页面加载
   */
    onLoad(options) {
        let that=this;
        //console.log(options.id)
       // console.log(options.teacherId)
        let teacherId=options.teacherId;
        let id=options.id;
        wx.request({
          url: app.globalData.URL+'course/findById/'+id,

          success(resp){
           // console.log(resp.data.data)
            that.setData({
                course:resp.data.data
            })
          }
        })
        wx.request({
            url: app.globalData.URL+'teacher/selectById/'+teacherId,
            success(resp){
             //console.log(resp.data.data)
              that.setData({
                  teacher:resp.data.data
              })
            }
          })


    },

})